.history-toolbar(
	ng-controller="HistoryV2ToolbarController"
	ng-if="ui.view == 'history' && history.isV2"
)
	span.history-toolbar-selected-version(ng-show="history.loadingFileTree")
		i.fa.fa-spin.fa-refresh
		| &nbsp;&nbsp; #{translate("loading")}...

	//- point-in-time mode info
	span.history-toolbar-selected-version(
		ng-show="!history.loadingFileTree && history.viewMode === HistoryViewModes.POINT_IN_TIME && !history.showOnlyLabels && currentUpdate && !history.error"
	) #{translate("browsing_project_as_of")}&nbsp;
		time.history-toolbar-time {{ currentUpdate.meta.end_ts | formatDate:'Do MMM YYYY, h:mm a' }}
	span.history-toolbar-selected-version(
		ng-show="!history.loadingFileTree && history.viewMode === HistoryViewModes.POINT_IN_TIME && history.showOnlyLabels && currentUpdate && !history.error"
	) 
		span(ng-if="currentUpdate.labels.length > 0") 
			| #{translate("browsing_project_labelled")}&nbsp;
			span.history-toolbar-selected-label(
				ng-repeat="label in currentUpdate.labels"
			) 
				| {{ label.comment }}
				span(ng-if="!$last") , 
		span.history-toolbar-selected-label(ng-if="currentUpdate.labels.length === 0 && history.labels[0].isPseudoCurrentStateLabel && currentUpdate.toV === history.labels[0].version")
			| #{translate("browsing_project_latest_for_pseudo_label")}



	//- compare mode info
	span.history-toolbar-selected-version(ng-if="history.viewMode === HistoryViewModes.COMPARE && history.selection.diff && !history.selection.diff.binary && !history.selection.diff.loading && !history.selection.diff.error && !history.loadingFileTree")
		| <strong>{{history.selection.diff.highlights.length}} </strong>
		ng-pluralize(
			count="history.selection.diff.highlights.length",
			when="{\
				'one': 'change',\
				'other': 'changes'\
			}"
		)
		|  in <strong>{{history.selection.diff.pathname}}</strong>

	//- point-in-time mode actions
	div.history-toolbar-actions(
		ng-if="history.viewMode === HistoryViewModes.POINT_IN_TIME && !history.error"
	)
		button.history-toolbar-btn(
			ng-click="showAddLabelDialog();"
			ng-if="!history.showOnlyLabels && permissions.write"
			ng-disabled="isHistoryLoading() || history.selection.range.toV == null || history.selection.range.fromV == null"
		) 
			i.fa.fa-tag
			| &nbsp;#{translate("history_label_this_version")}
		button.history-toolbar-btn(
			ng-click="toggleHistoryViewMode();"
			ng-disabled="isHistoryLoading()"
		) 
			i.fa.fa-exchange
			| &nbsp;#{translate("compare_to_another_version")}

		a.history-toolbar-btn-danger.pull-right(
			ng-hide="history.loadingFileTree || history.selection.range.toV == null"
			ng-href="/project/{{ project_id }}/version/{{ history.selection.range.toV }}/zip"
			target="_blank"
		) 
			i.fa.fa-download
			| &nbsp;#{translate("download_project_at_this_version")}



	//- compare mode actions
	div.history-toolbar-actions(
		ng-if="history.viewMode === HistoryViewModes.COMPARE && !history.error"
	)
		button.history-toolbar-btn(
			ng-click="toggleHistoryViewMode();"
			ng-disabled="isHistoryLoading()"
		) 
			i.fa
			| #{translate("view_single_version")}
		button.history-toolbar-btn-danger.pull-right(
			ng-if="history.selection.file.deletedAtV"
			ng-click="restoreDeletedFile()"
			ng-show="!restoreState.error"
			ng-disabled="restoreState.inflight"
		)
			i.fa.fa-fw.fa-step-backward
			span(ng-show="!restoreState.inflight")
				| Restore this deleted file
			span(ng-show="restoreState.inflight")
				| Restoring...
		span.text-danger(ng-show="restoreState.error")
			| Error restoring, sorry

	.history-toolbar-entries-list(
		ng-if="!history.error"
	)
		toggle-switch(
			ng-model="toolbarUIConfig.showOnlyLabels"
			label-true=translate("history_view_labels")
			label-false=translate("history_view_all")
			description=translate("history_view_a11y_description")
		)

script(type="text/ng-template", id="historyV2AddLabelModalTemplate")
	form(
		name="addLabelModalForm"
		ng-submit="addLabelModalFormSubmit();"
		novalidate
	)
		.modal-header
			h3 #{translate("history_add_label")}
		.modal-body
			.alert.alert-danger(ng-show="state.error.message") {{ state.error.message}} 
			.alert.alert-danger(ng-show="state.error && !state.error.message") #{translate("generic_something_went_wrong")}
			.form-group
				input.form-control(
					type="text"
					placeholder=translate("history_new_label_name")
					ng-model="inputs.labelName"
					focus-on="open"
					required
				)
			p.help-block(ng-if="update")
				| #{translate("history_new_label_added_at")} 
				strong {{ update.meta.end_ts | formatDate:'ddd Do MMM YYYY, h:mm a' }}
		.modal-footer
			button.btn.btn-default(
				type="button"
				ng-disabled="state.inflight"
				ng-click="$dismiss()"
			) #{translate("cancel")}
			input.btn.btn-primary(
				ng-disabled="addLabelModalForm.$invalid || state.inflight"
				ng-value="state.inflight ? '" + translate("history_adding_label") + "' : '" + translate("history_add_label") + "'"
				type="submit"
			)